package com.example.test;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

import com.libusb.jni.LibUsbMiddleWare;

import java.util.Calendar;

public class MainActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

	}

	@Override
	public void onClick(View v) {
		TextView tv = (TextView) v;

		switch (v.getId()) {
		case R.id.usb_cmd_ctrl_init:
			int res4 = LibUsbMiddleWare.usb_cmd_ctrl_init();

			Toast.makeText(this, "usb_cmd_ctrl_init:" + res4, 0).show();
			break;
		case R.id.usb_cmd_ctrl_exit:
			int res3 = LibUsbMiddleWare.usb_cmd_ctrl_exit();

			Toast.makeText(this, "usb_cmd_ctrl_exit:" + res3, 0).show();
			break;
		case R.id.stop_recording:

			int res2 = LibUsbMiddleWare.stop_recording();
			Toast.makeText(this, "stop_recording:" + res2, 0).show();
			break;
		case R.id.start_recording:
			int res = LibUsbMiddleWare.start_recording();

			Toast.makeText(this, "start_recording:" + res, 0).show();
			break;
		case R.id.set_date_time:
			Calendar c = Calendar.getInstance();
			int year = c.get(Calendar.YEAR);
			int month = c.get(Calendar.MONTH) + 1;
			int day = c.get(Calendar.DAY_OF_MONTH);
			int hour = c.get(Calendar.HOUR_OF_DAY);
			int minute = c.get(Calendar.MINUTE);
			int sec = c.get(Calendar.SECOND);

			
			Log.d("", "libusb:" + year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + sec);

			int res1 = LibUsbMiddleWare.set_date_time(year, month, day, hour, minute, sec);
			Toast.makeText(this, "set_date_time:" + res1, 0).show();
			break;
		case R.id.get_recording_status:

			int status = LibUsbMiddleWare.get_recording_status();

			Toast.makeText(this, "get_recording_status:" + status, 0).show();
			break;

		}

	}
}
